package com.example.dangerouscargodriver.ui.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.baiju.netmanager.Http.IHttpRequest;
import com.baiju.style.citylist.Toast.ToastUtils;
import com.bumptech.glide.Glide;
import com.example.dangerouscargodriver.R;
import com.example.dangerouscargodriver.controller.AuthController;
import com.example.dangerouscargodriver.entry.HandleRecordInfo;
import com.example.dangerouscargodriver.entry.MyResourceDetailInfo;
import com.example.dangerouscargodriver.entry.OrderDetailInfo;
import com.example.dangerouscargodriver.module.ResponseInfo;
import com.example.dangerouscargodriver.param.RemoteAPI;
import com.example.dangerouscargodriver.param.RemoteAPICmd;
import com.example.dangerouscargodriver.ui.view.QuotedPricePopupWindow;
import com.example.dangerouscargodriver.utils.DialogUtils;
import com.example.dangerouscargodriver.widget.ActionBar;
import com.example.dangerouscargodriver.widget.ChooseItemDialog;
import com.example.dangerouscargodriver.widget.HandleRecordInfoView;
import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class MyOrderDetailInfoActivity extends HttpRequestActivity implements View.OnClickListener {

    private static final String TAG = "MyOrderDetailInfoActivity";
    private static final String SERVICE_PHONE = "0571-88666547";

    private ActionBar mActionBar = null;
    private String mOrderId = null;
    private OrderDetailInfo mOrderDetailInfo = null;

    private ImageView mOrderStatusIcon = null;
    private TextView mOrderStatusName = null;
    private TextView mOrderStatusTitle = null;
    private TextView mTotalPrice = null;
    private TextView mPayType = null;
    private TextView mRegTime = null;
    private TextView mStartCity = null;
    private TextView mEndCity = null;
    private TextView mSourceDistance = null;
    private TextView mSourceWeight = null;
    private TextView mSourceType = null;
    private TextView mContact = null;
    private TextView mLoadTime = null;
    private TextView mRemark = null;
    private LinearLayout mLayoutContent = null;
    private LinearLayout mHandleRecord = null;
    private TextView mOrderNo = null;

    private LinearLayout mLayoutDiscussing = null;
    private LinearLayout mDiscussingOmitAction = null;
    private TextView mDiscussingCancelOrder = null;
    private TextView mDiscussingModifyPrice = null;

    private LinearLayout mLayoutTransporting = null;
    private LinearLayout mTransportingOmitAction = null;
    private TextView mTransportingConfirmArrive = null;

    private LinearLayout mLayoutOrderDone = null;
    private LinearLayout mOrderDoneOmitAction = null;
    private TextView mOrderDoneDeleteOrder = null;

    private LinearLayout mLayoutCanceling = null;
    private LinearLayout mCancelingOmitAction = null;
    private TextView mCancelingRefuse = null;
    private TextView mCancelingAgree = null;

    private LinearLayout mLayoutOrderLoseEfficacy = null;
    private LinearLayout mOrderLoseEfficacyOmitAction = null;
    private TextView mOrderLoseEfficacyDeleteOrder = null;

    private LinearLayout mLayoutCancelingRefuse = null;
    private LinearLayout mCancelingRefuseOmitAction = null;
    private TextView mCancelingRefuseOfficialService = null;

    private LinearLayout mLayoutWaitForConfirm = null;
    private LinearLayout mWaitForConfirmOmitAction = null;

    private QuotedPricePopupWindow mPopupWindow = null;
    private String mQuotedPrice = null;

    private List<String> mReasonItem = new ArrayList<>();

    private TextView mTransportMark = null;
    private TextView mTransportGrade = null;
    private LinearLayout mLayoutStarNum = null;
    private TextView mTransporterInfo = null;
    private LinearLayout mLayoutTransportView = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.initHttpComponent(MyOrderDetailInfoActivity.class);
        setContentView(R.layout.activity_order_detai_info);
        mOrderId = getIntent().getStringExtra("id");

        mReasonItem.add("货源信息不真实");
        mReasonItem.add("货主电话打不通");
        mReasonItem.add("货主出价比较低");
        mReasonItem.add("无法提供合适的车辆");
        mReasonItem.add("双方协商后取消");
        mReasonItem.add("程序操作不方便");
        mReasonItem.add("其他理由");

        mOrderStatusIcon = findViewById(R.id.iv_order_status_icon);
        mOrderStatusName = findViewById(R.id.tv_order_status_name);
        mOrderStatusTitle = findViewById(R.id.tv_order_status_title);
        mTotalPrice = findViewById(R.id.tv_total_price);
        mPayType = findViewById(R.id.tv_pay_type);
        mRegTime = findViewById(R.id.tv_reg_time);
        mStartCity = findViewById(R.id.item_start_city);
        mEndCity = findViewById(R.id.item_end_city);
        mSourceDistance = findViewById(R.id.tv_source_distance);
        mSourceWeight = findViewById(R.id.tv_source_weight);
        mSourceType = findViewById(R.id.tv_source_type);
        mContact = findViewById(R.id.tv_contact);
        mLoadTime = findViewById(R.id.tv_load_time);
        mRemark = findViewById(R.id.tv_remark);
        mLayoutContent = findViewById(R.id.layout_content);
        mHandleRecord = findViewById(R.id.layout_handle_record);
        mOrderNo = findViewById(R.id.tv_order_no);

        mLayoutDiscussing = findViewById(R.id.layout_discussing);
        mDiscussingOmitAction = findViewById(R.id.iv_discussing_omit_action);
        mDiscussingOmitAction.setOnClickListener(this);
        mDiscussingCancelOrder = findViewById(R.id.btn_discussing_cancel_order);
        mDiscussingCancelOrder.setOnClickListener(this);
        mDiscussingModifyPrice = findViewById(R.id.btn_discussing_modify_price);
        mDiscussingModifyPrice.setOnClickListener(this);

        mLayoutTransporting = findViewById(R.id.layout_transporting);
        mTransportingOmitAction = findViewById(R.id.btn_transporting_omit_action);
        mTransportingOmitAction.setOnClickListener(this);
        mTransportingConfirmArrive = findViewById(R.id.btn_transporting_confirm_arrive);
        mTransportingConfirmArrive.setOnClickListener(this);

        mLayoutOrderDone = findViewById(R.id.layout_order_done);
        mOrderDoneOmitAction = findViewById(R.id.btn_order_done_omit_action);
        mOrderDoneOmitAction.setOnClickListener(this);
        mOrderDoneDeleteOrder = findViewById(R.id.btn_order_done_order_delete);
        mOrderDoneDeleteOrder.setOnClickListener(this);

        mLayoutCanceling = findViewById(R.id.layout_order_canceling);
        mCancelingOmitAction = findViewById(R.id.btn_order_canceling_omit_action);
        mCancelingOmitAction.setOnClickListener(this);
        mCancelingRefuse = findViewById(R.id.btn_order_canceling_refuse);
        mCancelingRefuse.setOnClickListener(this);
        mCancelingAgree = findViewById(R.id.btn_order_canceling_agree);
        mCancelingAgree.setOnClickListener(this);

        mLayoutOrderLoseEfficacy = findViewById(R.id.layout_order_lose_efficacy);
        mOrderLoseEfficacyOmitAction = findViewById(R.id.btn_order_loss_efficacy_omit_action);
        mOrderLoseEfficacyOmitAction.setOnClickListener(this);
        mOrderLoseEfficacyDeleteOrder = findViewById(R.id.btn_order_loss_efficacy_order_delete);
        mOrderLoseEfficacyDeleteOrder.setOnClickListener(this);

        mLayoutCancelingRefuse = findViewById(R.id.layout_order_cancel_refuse);
        mCancelingRefuseOmitAction =findViewById(R.id.btn_order_cancel_refuse_omit_action);
        mCancelingRefuseOmitAction.setOnClickListener(this);
        mCancelingRefuseOfficialService = findViewById(R.id.btn_order_cancel_refuse_official_service);
        mCancelingRefuseOfficialService.setOnClickListener(this);

        mLayoutWaitForConfirm = findViewById(R.id.layout_order_wait_for_owner_to_confirm);
        mWaitForConfirmOmitAction = findViewById(R.id.iv_order_wait_for_owner_to_confirm_omit_action);

        mTransportMark = findViewById(R.id.tv_transport_mark);
        mTransportGrade = findViewById(R.id.tv_transport_grade);
        mLayoutStarNum = findViewById(R.id.layout_star_num);
        mTransporterInfo = findViewById(R.id.tv_transporter_info);
        mLayoutTransportView = findViewById(R.id.layout_transport_view);

        mActionBar = findViewById(R.id.actionBarMyOrderDetail);
        mActionBar.setOnBackClickListener( new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onResume(){
        super.onResume();
        executeGetOrderDetailInfo();
    }

    private void executeDiscussingCancelOrder(String reason){
        if(mOrderDetailInfo != null) {
            HashMap<String, String> header = new HashMap<String, String>();
            header.put("token", AuthController.Instance().getToken());

            JSONObject param = new JSONObject();
            try {
                param.put("type", 6);
                param.put("handling_reason", reason);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            sendHttpJsonRequest(
                    IHttpRequest.RequestMethod.PUT_METHOD,
                    RemoteAPI.REQUEST_V2_USER_SR_ORDER + "/" + mOrderId,
                    header,
                    param,
                    RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_DISCUSSING_CANCEL);
        }
        else{

        }
    }

    private void executeDeleteOrder(){
        if(mOrderDetailInfo != null) {
            HashMap<String, String> header = new HashMap<String, String>();
            header.put("token", AuthController.Instance().getToken());

            JSONObject param = new JSONObject();
            try {
                param.put("type", 5);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            sendHttpJsonRequest(
                    IHttpRequest.RequestMethod.PUT_METHOD,
                    RemoteAPI.REQUEST_V2_USER_SR_ORDER + "/" + mOrderId,
                    header,
                    param,
                    RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_DELETE);
        }
        else{

        }
    }

    private void executeSubmitPrice(){
        if(mOrderDetailInfo != null) {
            HashMap<String, String> header = new HashMap<String, String>();
            header.put("token", AuthController.Instance().getToken());

            JSONObject param = new JSONObject();
            try {
                param.put("id", mOrderId);
                param.put("total_final", mQuotedPrice);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            sendHttpJsonRequest(
                    IHttpRequest.RequestMethod.PUT_METHOD,
                    RemoteAPI.REQUEST_V2_USER_SUBMIT_PRICE,
                    header,
                    param,
                    RemoteAPICmd.REQUEST_V2_USER_SUBMIT_PRICE);
        }
        else{

        }
    }

    private void executeGetOrderDetailInfo(){
        if(mOrderId != null) {
            HashMap<String, String> header = new HashMap<String, String>();
            header.put("token", AuthController.Instance().getToken());

            sendHttpRequest(
                    IHttpRequest.RequestMethod.GET_METHOD,
                    RemoteAPI.REQUEST_V2_USER_SR_ORDER + "/" + mOrderId,
                    header,
                    null,
                    RemoteAPICmd.REQUEST_V2_USER_SG_ORDER);
        }
    }

    private void executeTransportingConfirmArrive(){
        if(mOrderDetailInfo != null) {
            HashMap<String, String> header = new HashMap<String, String>();
            header.put("token", AuthController.Instance().getToken());

            JSONObject param = new JSONObject();
            try {
                param.put("type", 4);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            sendHttpJsonRequest(
                    IHttpRequest.RequestMethod.PUT_METHOD,
                    RemoteAPI.REQUEST_V2_USER_SR_ORDER + "/" + mOrderId,
                    header,
                    param,
                    RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_TRANSPORTING_CONFIRM_ARRIVE);
        }
        else{

        }
    }

    private void executeTransportingCancelOrderAgree(){
        if(mOrderId != null) {
            HashMap<String, String> header = new HashMap<String, String>();
            header.put("token", AuthController.Instance().getToken());

            JSONObject param = new JSONObject();
            try {
                param.put("type", 3);
                param.put("is_agree", "1");
            } catch (JSONException e) {
                e.printStackTrace();
            }

            sendHttpJsonRequest(
                    IHttpRequest.RequestMethod.PUT_METHOD,
                    RemoteAPI.REQUEST_V2_USER_SR_ORDER + "/" + mOrderId,
                    header,
                    param,
                    RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_TRANSPORTING_CANCEL_AGREE);
        }
        else{

        }
    }

    private void refreshOrderDetailInfoView(){
        if(mOrderDetailInfo != null) {
            Glide.with(this).load(mOrderDetailInfo.getStatus_icon()).into(mOrderStatusIcon);
            mOrderStatusName.setText(mOrderDetailInfo.getOrder_statusname());
            mOrderStatusTitle.setText(mOrderDetailInfo.getStatus_desc());
            mTotalPrice.setText(mOrderDetailInfo.getTotal_final());
            if(mOrderDetailInfo.getPay_type().equals("2")){
                mPayType.setText(R.string.tv_pay_online);
            }
            else{
                mPayType.setText(R.string.tv_pay_offline);
            }
            mRegTime.setText(mOrderDetailInfo.getOrder_sr_order_create_time());
            mStartCity.setText(mOrderDetailInfo.getOrder_sg_from_city());
            mEndCity.setText(mOrderDetailInfo.getOrder_sg_to_city());
            mSourceDistance.setText(mOrderDetailInfo.getOrder_sg_distance());
            mSourceWeight.setText(mOrderDetailInfo.getOrder_sg_weight() + "吨");
            mSourceType.setText(mOrderDetailInfo.getOrder_sg_core_attr());
            mContact.setText(mOrderDetailInfo.getOrder_sg_contact());
            mLoadTime.setText(mOrderDetailInfo.getLoadtime());
            mRemark.setText(mOrderDetailInfo.getOrder_sr_remark());

            if(mOrderDetailInfo.getOrder_sg_name() != null && !mOrderDetailInfo.getOrder_sg_name().equals("")){
                View layout = LayoutInflater.from(this).inflate(R.layout.layout_resource_meta_info_item, null);
                TextView textView = layout.findViewById(R.id.tv_item_meta_string);
                textView.setText(mOrderDetailInfo.getOrder_sg_name());
                mLayoutContent.addView(layout);
            }
            if(mOrderDetailInfo.getOrder_sg_truck() != null && mOrderDetailInfo.getOrder_sg_truck().size() > 0){
                List<String> truckTypeArray = mOrderDetailInfo.getOrder_sg_truck();

                for(int index = 0; index < truckTypeArray.size(); index++){
                    View layout = LayoutInflater.from(this).inflate(R.layout.layout_resource_meta_info_item, null);
                    TextView textView = layout.findViewById(R.id.tv_item_meta_string);
                    textView.setText(truckTypeArray.get(index));
                    mLayoutContent.addView(layout);
                }
            }

            mOrderNo.setText(mOrderDetailInfo.getOrder_sr_order_number());

            List<HandleRecordInfo> record = mOrderDetailInfo.getHandle_record();
            if(record != null && record.size() > 0){
                mHandleRecord.removeAllViews();
                for(int index = 0; index < record.size(); index++){
                    HandleRecordInfoView view = new HandleRecordInfoView(this, record.get(index));
                    mHandleRecord.addView(view);
                }
            }

            if(mOrderDetailInfo.getOrder_status().equals("7")){
                mLayoutDiscussing.setVisibility(View.VISIBLE);
                mLayoutTransporting.setVisibility(View.GONE);
                mLayoutOrderDone.setVisibility(View.GONE);
                mLayoutCanceling.setVisibility(View.GONE);
                mLayoutCancelingRefuse.setVisibility(View.GONE);
                mLayoutOrderLoseEfficacy.setVisibility(View.GONE);
                mLayoutWaitForConfirm.setVisibility(View.GONE);
            }
            else if(mOrderDetailInfo.getOrder_status().equals("1")){
                mLayoutDiscussing.setVisibility(View.GONE);
                mLayoutTransporting.setVisibility(View.VISIBLE);
                mLayoutOrderDone.setVisibility(View.GONE);
                mLayoutCanceling.setVisibility(View.GONE);
                mLayoutCancelingRefuse.setVisibility(View.GONE);
                mLayoutOrderLoseEfficacy.setVisibility(View.GONE);
                mLayoutWaitForConfirm.setVisibility(View.GONE);
            }
            else if(mOrderDetailInfo.getOrder_status().equals("8")){
                mLayoutWaitForConfirm.setVisibility(View.VISIBLE);
                mLayoutDiscussing.setVisibility(View.GONE);
                mLayoutTransporting.setVisibility(View.GONE);
                mLayoutOrderDone.setVisibility(View.GONE);
                mLayoutCanceling.setVisibility(View.GONE);
                mLayoutCancelingRefuse.setVisibility(View.GONE);
                mLayoutOrderLoseEfficacy.setVisibility(View.GONE);
            }
            else if(mOrderDetailInfo.getOrder_status().equals("4")){
                mLayoutDiscussing.setVisibility(View.GONE);
                mLayoutTransporting.setVisibility(View.GONE);
                mLayoutOrderDone.setVisibility(View.VISIBLE);
                mLayoutCanceling.setVisibility(View.GONE);
                mLayoutCancelingRefuse.setVisibility(View.GONE);
                mLayoutOrderLoseEfficacy.setVisibility(View.GONE);
                mLayoutWaitForConfirm.setVisibility(View.GONE);
            }
            else if(mOrderDetailInfo.getOrder_status().equals("9")){
                if(mOrderDetailInfo.getIs_refuse() != null && mOrderDetailInfo.getIs_refuse().equals("1")){
                    mLayoutCancelingRefuse.setVisibility(View.VISIBLE);
                    mLayoutCanceling.setVisibility(View.GONE);
                }
                else {
                    mLayoutCanceling.setVisibility(View.VISIBLE);
                    mLayoutCancelingRefuse.setVisibility(View.GONE);
                }
                mLayoutDiscussing.setVisibility(View.GONE);
                mLayoutTransporting.setVisibility(View.GONE);
                mLayoutOrderDone.setVisibility(View.GONE);
                mLayoutOrderLoseEfficacy.setVisibility(View.GONE);
                mLayoutWaitForConfirm.setVisibility(View.GONE);
            }
            else if(mOrderDetailInfo.getOrder_status().equals("2") ||
                    mOrderDetailInfo.getOrder_status().equals("5") ||
                    mOrderDetailInfo.getOrder_status().equals("6")){
                mLayoutDiscussing.setVisibility(View.GONE);
                mLayoutTransporting.setVisibility(View.GONE);
                mLayoutOrderDone.setVisibility(View.GONE);
                mLayoutCanceling.setVisibility(View.GONE);
                mLayoutCancelingRefuse.setVisibility(View.GONE);
                mLayoutOrderLoseEfficacy.setVisibility(View.VISIBLE);
                mLayoutWaitForConfirm.setVisibility(View.GONE);
            }

            mLayoutTransportView.setVisibility(View.VISIBLE);
            mTransporterInfo.setText(mOrderDetailInfo.getTruck_name());
            mTransportGrade.setText(mOrderDetailInfo.getTruck_grade()+ "分");

            int grade = (int) Float.parseFloat(mOrderDetailInfo.getTruck_grade());
            for(int index = 0; index < grade; index++){
                View layout = LayoutInflater.from(this).inflate(R.layout.layout_grade_star_item, null);
                mLayoutStarNum.addView(layout);
            }
            mTransportMark.setText(mOrderDetailInfo.getOrder_sr_remark());
        }
    }

    @SuppressLint("LongLogTag")
    @Override
    protected void onHttpResponse(int actionId, String response) {
        try {
            JSONObject res = new JSONObject(response);
            Gson gson = new Gson();
            if(actionId == RemoteAPICmd.REQUEST_V2_USER_SG_ORDER){
                Log.d(TAG, "onResponse: " + response);
                ResponseInfo responseInfo = gson.fromJson(response, ResponseInfo.class);
                if(responseInfo != null && responseInfo.getStatus() == 1){
                    mOrderDetailInfo =gson.fromJson(res.getString("data"), OrderDetailInfo.class);
                    refreshOrderDetailInfoView();
                }
            }
            if(actionId == RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_DISCUSSING_CANCEL){
                Log.d(TAG, "onResponse: " + response);
                ResponseInfo responseInfo = gson.fromJson(response, ResponseInfo.class);
                if(responseInfo != null && responseInfo.getStatus() == 1){
                    executeGetOrderDetailInfo();
                }
            }
            if(actionId == RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_DELETE){
                Log.d(TAG, "onResponse: " + response);
                ResponseInfo responseInfo = gson.fromJson(response, ResponseInfo.class);
                ToastUtils.showLongToast(this, res.getString("message"));
                if(responseInfo != null && responseInfo.getStatus() == 1){
                    finish();
                }
            }
            if(actionId == RemoteAPICmd.REQUEST_V2_USER_SUBMIT_PRICE){
                Log.d(TAG, "onResponse: " + response);
                ResponseInfo responseInfo = gson.fromJson(response, ResponseInfo.class);
                ToastUtils.showLongToast(this, res.getString("message"));
                if(responseInfo != null && responseInfo.getStatus() == 1){
                    executeGetOrderDetailInfo();
                }
            }
            if(actionId == RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_TRANSPORTING_CONFIRM_ARRIVE){
                Log.d(TAG, "onResponse: " + response);
                ResponseInfo responseInfo = gson.fromJson(response, ResponseInfo.class);
                ToastUtils.showLongToast(this, res.getString("message"));
                if(responseInfo != null && responseInfo.getStatus() == 1){
                    executeGetOrderDetailInfo();
                }
            }
            else if(actionId == RemoteAPICmd.REQUEST_V2_USER_SR_ORDER_TRANSPORTING_CANCEL_AGREE){
                Log.d(TAG, "onResponse: " + response);
                ResponseInfo responseInfo = gson.fromJson(response, ResponseInfo.class);
                ToastUtils.showLongToast(this, res.getString("message"));
                if(responseInfo != null && responseInfo.getStatus() == 1){
                    finish();
                }
                else{

                }
            }
            else{

            }
        }
        catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onHttpErrorResponse(int actionId, String response) {

    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.iv_discussing_omit_action){

        }
        else if(v.getId() == R.id.btn_discussing_cancel_order){
            //议价中取消订单
            ChooseItemDialog dialog = new ChooseItemDialog(this,
                    "确认取消",
                    "取消后，货物可能被他人接单哦\n请选择取消理由",
                    mReasonItem,
                    "确认",
                    "取消"
            );
            dialog.addClickListener(new ChooseItemDialog.AlertDialogBtnClickListener() {
                @Override
                public void clickPositive(List<Integer> select) {
                    String reason = "";
                    for(int index = 0; index < select.size(); index++){
                        reason += mReasonItem.get(index) + ",";
                    }
                    if(reason.length() > 0){
                        reason = reason.substring(0, reason.length() - 1);
                    }
                    executeDiscussingCancelOrder(reason);
                }

                @Override
                public void clickNegative() {

                }
            });
            dialog.showAlertDialog(false);
        }
        else if(v.getId() == R.id.btn_discussing_modify_price){
            //议价中修改报价
            if(mPopupWindow == null){
                mPopupWindow = new QuotedPricePopupWindow(this);
            }
            mPopupWindow.setPrice(Float.parseFloat(mOrderDetailInfo.getTotal_final()));
            mPopupWindow.setInputListener(new QuotedPricePopupWindow.onInputListener() {
                @Override
                public void onInput(String price) {
                    mQuotedPrice = price;
                    executeSubmitPrice();
                }
            });
            mPopupWindow.showPopupWindow(true);
        }
        else if(v.getId() == R.id.iv_transporting_omit_action){

        }
        else if(v.getId() == R.id.btn_transporting_confirm_arrive){
            //确认送达
            executeTransportingConfirmArrive();
        }
        else if(v.getId() == R.id.btn_order_done_omit_action){

        }
        else if(v.getId() == R.id.btn_order_done_order_delete){
            //删除订单
            DialogUtils.showAlertDialog(this,
                    "确认删除",
                    "确认要删除该订单吗？",
                    "确定",
                    "取消",
                    false,
                    new DialogUtils.AlertDialogBtnClickListener() {
                        @Override
                        public void clickPositive() {
                            //negative
                            executeDeleteOrder();
                        }
                        @Override
                        public void clickNegative() {
                            //positive
                        }
                    });
        }
        else if(v.getId() == R.id.btn_order_canceling_omit_action){

        }
        else if(v.getId() == R.id.btn_order_canceling_refuse){
            //拒绝取消订单
            Intent intent = new Intent(this, RefuseCancelOrderActivity.class);
            intent.putExtra("id", mOrderId);
            startActivity(intent);
        }
        else if(v.getId() == R.id.btn_order_canceling_agree){
            //同意取消订单
            DialogUtils.showAlertDialog(this,
                    "同意取消",
                    "请确认是否同意货主取消订单",
                    "同意",
                    "取消",
                    false,
                    new DialogUtils.AlertDialogBtnClickListener() {
                        @Override
                        public void clickPositive() {
                            //negative
                            executeTransportingCancelOrderAgree();
                        }
                        @Override
                        public void clickNegative() {
                            //positive
                        }
                    });
        }
        else if(v.getId() == R.id.btn_order_loss_efficacy_omit_action){

        }
        else if(v.getId() == R.id.btn_order_loss_efficacy_order_delete){
            //删除订单
            DialogUtils.showAlertDialog(this,
                    "确认删除",
                    "确认要删除该订单吗？",
                    "确定",
                    "取消",
                    false,
                    new DialogUtils.AlertDialogBtnClickListener() {
                        @Override
                        public void clickPositive() {
                            //negative
                            executeDeleteOrder();
                        }
                        @Override
                        public void clickNegative() {
                            //positive
                        }
                    });
        }
        else if(v.getId() == R.id.btn_order_cancel_refuse_omit_action){

        }
        else if(v.getId() == R.id.btn_order_cancel_refuse_official_service){
            Intent dialIntent =  new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + SERVICE_PHONE));//跳转到拨号界面，同时传递电话号码
            startActivity(dialIntent);
        }
        else{

        }
    }
}